(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/resources/Script/Ssg/Utils/ShareUtil.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, '43562J+belJDIc6z9jdR9gn', 'ShareUtil', __filename);
// resources/Script/Ssg/Utils/ShareUtil.js

'use strict';

window.ShareUtil = function () {
    var _static = {
        shareInfo: null,

        setShareInfo: function setShareInfo(shareInfo) {
            this.shareInfo = shareInfo;
        },

        startShare: function startShare(callback, shareType) {
            if (SystemInfo.getPlatform() != 'weChatGame' && SystemInfo.getPlatform() != 'weChat' && SystemInfo.getPlatform() != 'qqPlay') {
                Log.info("没有分享功能的平台，直接返回成功");
                callback(true);
                return;
            }
            if (!shareType) {
                shareType = "default";
            }
            if (SystemInfo.getPlatform() == 'weChatGame' || SystemInfo.getPlatform() == 'weChat') {
                //微信渠道
                this.shareWX(shareType, callback);
            } else if (SystemInfo.getPlatform() == 'qqPlay') {
                //QQ渠道
                this.shareQQ(shareType, callback);
            }
        },
        /**
        * 微信分享
        */
        shareWX: function shareWX(shareType, callback) {
            //开始分享
            wx.shareAppMessage({
                title: this.shareInfo[shareType].title,
                imageUrl: this.shareInfo[shareType].shareImgUrl,
                query: this.shareInfo[shareType].exetInfo ? this.shareInfo[shareType].exetInfo : UserInfo.userId,
                success: function success(res) {
                    Log.info("分享成功");
                    callback(true);
                },
                fail: function fail(res) {
                    Log.info("分享失败");
                    callback(false);
                }
            });
        },

        /**
         * QQ分享
         */
        shareQQ: function shareQQ(shareTitle, shareImgUrl, shareQuery, callback) {
            //分享内容、图片地址、查询参数、回调
            BK.Share.share({
                qqImgUrl: this.shareInfo[shareType].shareImgUrl,
                socialPicPath: this.shareInfo[shareType].localImgUrl,
                title: this.shareInfo[shareType].title,
                summary: this.shareInfo[shareType].content,
                extendInfo: this.shareInfo[shareType].exetInfo ? this.shareInfo[shareType].exetInfo : UserInfo.userId,
                success: function success(succObj) {
                    BK.Console.log('分享成功', succObj.code, JSON.stringify(succObj.data));
                    if (succObj.data.ret == 0) {
                        callback(true);
                    } else {
                        callback(false);
                    }
                },
                fail: function fail(failObj) {
                    BK.Console.log('分享失败', failObj.code, JSON.stringify(failObj.msg));
                    callback(false);
                },
                complete: function complete() {
                    BK.Console.log('分享完成，不论成功失败');
                }
            });
        },

        //显示当前页面的转发按钮
        showShareMenu: function showShareMenu(back) {
            wx.showShareMenu({
                imageUrl: '/res/raw-assets/resources/Texture/zhujiemian.png',
                success: back('success'),
                fail: back('fail')
            });
        },

        //隐藏当前页面的转发按钮
        hideShareMenu: function hideShareMenu(back) {
            wx.hideShareMenu({
                success: back('success'),
                fail: back('fail')
            });
        }

    };
    return _static;
}();

module.exports = ShareUtil;

cc._RF.pop();
        }
        if (CC_EDITOR) {
            __define(__module.exports, __require, __module);
        }
        else {
            cc.registerModuleFunc(__filename, function () {
                __define(__module.exports, __require, __module);
            });
        }
        })();
        //# sourceMappingURL=ShareUtil.js.map
        